package com.ecas.code.generator.dto;

import lombok.Data;

import java.io.Serializable;

@Data
public final class ResultBean<T> implements Serializable{
    private static final long serialVersionUID = -2445158857741065519L;
    private static final Integer CODE_200 = 200;
    private static final Integer CODE_500 = 500;
    private static final String SUCCESS = "success";
    private static final String FAIL = "fail";
    private Integer code;
    private String message;
    private T data;

    public void setPageResultBean(T data) {
        if (data != null) {
            code = CODE_200;
            message = SUCCESS;
        } else {
            code = CODE_500;
            message = FAIL;
        }
        this.data = data;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

}
